package com.xiaohe66.web.domain.im.value;

import com.xiaohe66.common.ex.BusinessException;
import com.xiaohe66.common.value.ErrorCodeEnum;
import com.xiaohe66.web.integration.domain.IntValue;
import lombok.EqualsAndHashCode;

/**
 * @author xiaohe
 * @since 2023.08.09 16:10
 */
@EqualsAndHashCode(callSuper = true)
public class MessageState extends IntValue {

    public static final MessageState READ = new MessageState(1);
    public static final MessageState UNREAD = new MessageState(0);

    private MessageState(Integer value) {
        super(value);
    }

    public static MessageState valueOf(int value) {
        return switch (value) {
            case 1 -> READ;
            case 0 -> UNREAD;
            default -> throw new BusinessException(ErrorCodeEnum.ERROR);
        };
    }

    @Override
    public String toString() {
        return "SysMessageState(" + getValue() + ")";
    }
}
